package PackagesTests;

import ArithUtils.BigNumber;
import ArithmeticObjects.BTField;
import ArithmeticObjects.VerfGroup;
import ArithmeticObjects.staticTypes;
import CryptoPrim.CiphertextGroup;
import CryptoPrim.PlaintextGroup;
import Utils.ProofDirectoryParam;
import Utils.ProtocolInfo;

/**
 * A tester class for ProofDirectoryParam class.
 * 
 * @author Itamar Carmel
 */
public class ProofDirectoryParamTest {
	
	private static String directory = "C:\\TESTS\\test1\\default";
	private static String prot_file_path = "C:\\TESTS\\test1\\protInfo.xml";

	public static void main(String[] args) throws Exception{
		
		ProtocolInfo protInfo  = new ProtocolInfo(prot_file_path );
		VerfGroup Gq = protInfo.getGroup();
		
		ProofDirectoryParam pdp;
		try {
			pdp = new ProofDirectoryParam(directory );
		} catch (Exception e) {
			e.printStackTrace();
			System.err.println("Loading proof directory failed.");
			return;
		}
		
		System.out.println("Version: " + pdp.getVersion());
		System.out.println("Type: " + pdp.getType());
		System.out.println("Auxsid: " + pdp.getAuxsid());
		System.out.println("Width: " + pdp.getWidth());
		System.out.println("Maxciph: " + pdp.getMaxciph());
		System.out.println("* LOADING BYTE TREE FILES *");
		
		CiphertextGroup Cw = new CiphertextGroup(Gq,pdp.getWidth());
		PlaintextGroup Mw = new PlaintextGroup(Gq,pdp.getWidth());
		BTField<BigNumber> Zq = staticTypes.getNumberField(Gq.getOrder());
		
		System.out.println("FullPublicKey.bt: " + (pdp.getFullPublicKey(Gq) != null));
		System.out.println("Ciphertexts.bt: " + (pdp.getInputCiphertexts(Cw)!= null));
		System.out.println("Plaintexts.bt: " + (pdp.getPlaintexts(Mw) != null));
		System.out.println("ShuffledCiphertexts.bt: " + (pdp.getShuffledCiphertexts(Cw) != null));
		for (int l=1; l<=protInfo.getLambda(); l++){
			System.out.println(l + "'th Mix-Server:");
			System.out.println("PublicKey"+l+".bt: " + (pdp.getPartialPublicKey(l,Gq) != null));
			System.out.println("SecretKey"+l+".bt: " + (pdp.getSecretKey(l,Zq) != null));
			System.out.println("Ciphertexts"+l+".bt: " + (pdp.getCiphertexts(l,Cw) != null));
			System.out.println("PermutationCommitment"+l+".bt: " + (pdp.getPermutationCommitment(l,Gq) != null));
			System.out.println("PoSCommitment"+l+".bt: " + (pdp.getPoSCommitment(l)!= null));
			System.out.println("PoSReply"+l+".bt: " + (pdp.getPoSReply(l) != null));
			System.out.println("PoSCCommitment"+l+".bt: " + (pdp.getPoSCCommitment(l) != null));
			System.out.println("PoSCReply"+l+".bt: " + (pdp.getPoSCReply(l) != null));
			System.out.println("KeepList"+l+".bt: " + (pdp.getKeepList(l) != null));
			System.out.println("CCPoSCommitment"+l+".bt: " + (pdp.getCCPoSCommitment(l) != null));
			System.out.println("CCPoSReply"+l+".bt: " + (pdp.getCCPoSReply(l) != null));
			System.out.println("DecryptionFactors"+l+".bt: " + (pdp.getDecryptionFactors(l,Mw) != null));
			System.out.println("DecrFactCommitment"+l+".bt: " + (pdp.getDecrFactCommitment(l) != null));
			System.out.println("DecrFactReply"+l+".bt: " + (pdp.getDecrFactReply(l) != null));
		}
	}
}
